package com.douqu.game.battle.controller;

import com.douqu.game.battle.controller.sprite.SpriteController;
import com.douqu.game.battle.entity.tmp.MonsterBattleTmp;
import com.douqu.game.battle.entity.tmp.SpriteBattleTmp;
import com.douqu.game.battle.util.BattleUtils;
import com.douqu.game.core.astar.AStar;
import com.douqu.game.core.astar.AstarMap;
import com.douqu.game.core.config.challenge.MapConfig;
import com.douqu.game.core.e.E_BattleDetailType;
import com.douqu.game.core.entity.battle.BattleInitParam;
import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.protobuf.SGCommonProto;
import com.douqu.game.core.util.LogUtils;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-05-31 17:39
 */
public class EVEController extends BattleController {


    public EVEController(String battleId, SpriteController source, SpriteController target, SGCommonProto.E_BATTLE_TYPE battleType, E_BattleDetailType battleDetailType, String targetData, String targetName, BattleInitParam initParam)
    {
        super(battleId, source, target, battleType, battleDetailType, targetData, targetName, initParam);

        this.targetData = targetData;

        MapConfig mapConfig = DataFactory.getInstance().getGameObject(DataFactory.MAP_KEY, initParam.getMapId());
        LogUtils.debug("mapConfig -> " + mapConfig);
        this.astar = new AStar(new AstarMap(AstarMap.AnchorPos.BottomLeft, mapConfig.mapType==1? BattleUtils.BATTLE_MAP_1:BattleUtils.BATTLE_MAP_2));
    }

    @Override
    public void init()
    {
        super.init();

        SpriteBattleTmp pbt2 = new MonsterBattleTmp();
        pbt2.setReady(true);
        pbt2.init(this, target, ConstantFactory.BATTLE_TEAM_2);
        target.setAttachment(pbt2);

        pbt2.setTargetBattleTmp(source.getAttachment());
        source.getAttachment().setTargetBattleTmp(pbt2);

        battleDetail.getTeam2Info().setMaster(pbt2.getMasterSoldier().getSpriteTemp());

        readyStart();
    }
}
